package momoshenchi.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @version : 1.0
 * @author: momoshenchi
 * @date: 2021/3/5 - 20:58
 */
@Configuration
public class RabbitMQConfig
{
    public static  final  String EX_NAME="exchange";
    public static  final  String QUEUE_NAME="queued";

    @Bean
    public Exchange bootEXchange()
    {
        return ExchangeBuilder.topicExchange(EX_NAME).durable(true).build();
    }

    @Bean
    public Queue bootQueue()
    {

        return QueueBuilder
                .durable(QUEUE_NAME)
                .ttl(5000)
                .maxLength(10)
                .deadLetterExchange("testExchange")
                .deadLetterRoutingKey("dlx.xx")
                .build();
    }

    @Bean
    public Binding binding()
    {
        return  BindingBuilder.bind(bootQueue()).to(bootEXchange()).with("boot.#").noargs();
    }

    @Bean
    public Exchange testExchange()
    {
        return ExchangeBuilder.topicExchange("testExchange").durable(true).build();
    }
    @Bean
    public  Queue testDlx()
    {
        return  QueueBuilder.durable("testDlx").build();
    }
    @Bean
    public Binding binding2()
    {
        return  BindingBuilder.bind(testDlx()).to(testExchange()).with("dlx.#").noargs();
    }


}
